package com.tanhua.config.properties;

import com.baidu.aip.face.AipFace;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

@Data
@ConfigurationProperties(prefix = "tanhua.face")
public class FaceProperties {

    private String appId;
    private String apiKey;
    private String secretKey ;

    /**
     * 根据百度人脸识别文档，最好是单例模式
     * @return
     */
    @Bean
    public AipFace aipFace(){
        //1.初始化一个AipFace
        AipFace client = new AipFace(appId,apiKey,secretKey);

        //2.设置网络连接参数（可选）
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);

        return client;
    }
}
